package itu.dk.bosk.ex3;

import java.io.IOException;
import java.io.Writer;

public class WriterFork extends Writer {
 
	private Writer writerA;
	private Writer writerB;
	
	public WriterFork( Writer writerA, Writer writerB ) { 
	   this.writerA = writerA;
	   this.writerB = writerB;
	}
	
	@Override
	public void close() throws IOException {
		writerA.close();
		writerB.close();
	}

	@Override
	public void flush() throws IOException {
		writerA.flush();
		writerB.flush();
	}

	@Override
	public void write(char[] arg0, int arg1, int arg2) throws IOException {
		writerA.write(arg0, arg1, arg2);
		writerB.write(arg0, arg1, arg2);
	}

	public void write(String arg0, int arg1, int arg2) throws IOException {
		writerA.write(arg0, arg1, arg2);
		writerB.write(arg0, arg1, arg2);
	}
	
	public void write(String arg0) throws IOException {
		writerA.write(arg0);
		writerB.write(arg0);
	}
}
